// components/idleTabBar/idleTabBar.js
import { getStorage } from "../../utils/utils"

Component({
  /**
   * 组件的属性列表
   */
  properties: {
     select: {//选择的标签
      type: Number,
      value: 0
     },
     hasNotice: {//是否有未读消息
      type: Boolean,
      value: false
     } 
  },

  /**
   * 组件的初始数据
   */
  data: {
     list:[
       {title: '首页',pagePath:'/pages/idleHome/idleHome',iconPath:'https://image-classify.daieco.com/kejian-second/h8JczsWkAzmh15e6868f0d5911d994dbfa657dbe23ed.png'},
       {title: '消息',pagePath:'/pages/conversation/conversation',iconPath:'https://image-classify.daieco.com/kejian-second/SVjmqKxqDh0Ade7b002d784dcfe212d056159297e078.png'},
       {title: '我的',pagePath:'/pages/idleOrder/idleOrder',iconPath:'https://image-classify.daieco.com/kejian-second/oWWVSTPyQbtL3f34292231efa1cf0a5f13b0c95571c4.png'},
       {title: '发布',pagePath:'/pages/idleRelease/idleRelease',iconPath:'https://image-classify.daieco.com/kejian-second/xLbW3ekbxOex2771d651172bedf54591ade1da2e65ab.png'},
     ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    //跳转页面
    jump(e){
      let path= e.currentTarget.dataset.path
      // 首页不跳转
      if(path === '/pages/idleHome/idleHome') return
      //跳转发布页，校验绑定小区
      if(path==='/pages/idleRelease/idleRelease'){
        let communityBind= getStorage('communityBind')
        if (!communityBind) {
          wx.showModal({
            content: "请先绑定小区!",
            confirmText: "去绑定",
            success: function (res) {
              if (res.confirm) {
                wx.navigateTo({
                  url: `/pages/idleCommunityList/idleCommunityList`,
                });
              }
            },
          });
          return false;
        } else {
          wx.navigateTo({
            url: path,
          });
        }
      }else{
        wx.navigateTo({
          url: path
        })
      }
      this.triggerEvent('click')
    }
  }
})
